//
//  MyScrollView.m
//  UI06_UIScorllView_相册
//
//  Created by LGC on 16/3/16.
//  Copyright © 2016年 Apon. All rights reserved.
//


#define WIDTH frame.size.width
#define HEIGHT frame.size.height

#import "MyScrollView.h"

@implementation MyScrollView

#pragma mark - Creating and Init
- (instancetype)initWithFrame:(CGRect)frame withImages:(NSArray<UIImage *> *)images {
    
    self = [super initWithFrame:frame];
    
    if (self) {
        [self configWithFrame:frame andImages:images];
    }

    return self;
    
}

- (void)configWithFrame:(CGRect)frame andImages:(NSArray<UIImage *> *)images{
    
    // 设置contentSize
    self.contentSize = CGSizeMake(WIDTH * images.count, HEIGHT );
    
    // 创建imageView子视图.
    for (int i = 0; i < images.count; i++) {
        
        
        UIImageView *imageView = [[UIImageView alloc] initWithImage:images[i]];
        
        imageView.frame = CGRectMake(WIDTH * i, 0, WIDTH, HEIGHT);
        
        [self addSubview: imageView];
        
        [imageView release];
        
    
    }
    
    // 开启翻页效果(默认是NO)
    self.pagingEnabled = YES;
    
    // 边缘回弹效果(默认是YES)
    self.bounces = YES;
    
    // 滑动指示器(默认是YES)
    self.showsHorizontalScrollIndicator = YES;
    
}


@end
